package com.vrv.common.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 静态数据工具类
 * 
 * @author caobl
 * 
 */
public class DataSetUtil {

	/**
	 * 过滤掉三级导航和四级导航中没有绑定activity的数据
	 * 
	 * @param groups
	 * @param childs
	 */
	public static void checkDataSource(List<Map<String, String>> groups, List<List<Map<String, String>>> childs) {

		List<Map<String, String>> rawGroups = new ArrayList<Map<String, String>>();
		List<List<Map<String, String>>> rawChilds = new ArrayList<List<Map<String, String>>>();

		for (int i = 0; i < groups.size(); i++) {
			int childSize = childs.get(i).size();
			if (childs.get(i).size() > 0) {
				List<Map<String, String>> varList = new ArrayList<Map<String, String>>();
				for (int j = 0; j < childSize; j++) {
					String activityName = childs.get(i).get(j).get("activityName");
					if (StringUtils.isNotBlank(activityName)) {
						varList.add(childs.get(i).get(j));
					}
				}

				if (varList.size() > 0) {
					rawGroups.add(groups.get(i));
					rawChilds.add(varList);
					// rawChilds.add(childs.get(i));
				}
			} else if (StringUtils.isNotBlank(groups.get(i).get("activityName"))) {
				rawGroups.add(groups.get(i));
				rawChilds.add(childs.get(i));
			}
		}
		groups.clear();
		childs.clear();

		groups.addAll(rawGroups);
		childs.addAll(rawChilds);
	}
}
